<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>doucument应用</title>
</head>
<body>
<!--<p id = "p1" name = "pname">这是一个p标签</p>-->
<!--<a href="#" id = "a1">这是一个a标签</a>-->





<script>
    // window.document.write("<h1 id = 'ht'>hello,word!</h1>");
    //
    // let p1 = window.document.getElementById("p1");
    // console.log(p1);
    // console.log("innertext:" + p1.innerText);
    // //p1.innerText = "helloworld!"
    // console.log("innerHTML:" + p1.innerHTML);
    // let ht = window.document.getElementById("ht");
    // console.log(ht);
    //
    // let pnames = window.document.getElementsByName("pname");//name可以重名,所以输出来的是数组
    // console.log(pnames[0]);
    //
    // let tag = window.document.getElementsByTagName("a");
    // console.log(tag[0]);

     //let now = new Date();
    // // console.log(now);
    // // window.document.write(now);
    // let year = now.getFullYear();
    // let month = now.getMonth();
    // let day = now.getDate();
    // let hour = now.getHours();
    // let minute = now.getMinutes();
    // let second = now.getSeconds();
    // nowstr = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
    //  window.document.write(nowstr);

    function test1() {
        let now = new Date();
        let year = now.getFullYear();
        let month = now.getMonth();
        let day = now.getDate();
        let hour = now.getHours();
        let minute = now.getMinutes();
        let second = now.getSeconds();
        nowstr = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
        window.document.body.innerText = nowstr;
    }
    window.setInterval(test1,1000);
</script>
</body>
</html>